<%@ page contentType="text/html;charset=UTF-8" %>﻿
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta content="" name="description"/>
<meta content="" name="author"/>

<link rel="stylesheet" type="text/css" href="${ctx}/static/js/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/js/themes/IconExtension.css" />
<script type="text/javascript">
var datagrid;
var rowEditor=undefined;
function searchWorkBill(){
	var ctx_val = $("#context_val").val();
	
	var customerPhone = $("#customerPhone").val();
	var billStt = $('#billStt').combobox('getValue');
	var emergentType = $('#emergentType').combobox('getValue');
	var deployEmpName = $("#deployEmpName").val();
	
	datagrid=$("#data").datagrid({
		url:ctx_val+"/installBill/selectInstallBill",//加载的URL
		method:"post",
		queryParams: { 
			'customerPhone': customerPhone ,
			'billStt':billStt,
			'emergentType':emergentType,
			'deployEmpName':deployEmpName
		},
	    isField:"id",
		pagination:true,//显示分页
		pageSize:5,//分页大小
		pageList:[5,10,15,20],//每页的个数
		fit:true,//自动补全
		fitColumns:true,
		iconCls:"icon-save",//图标
		title:"安装单查询",
		columns:[[     //每个列具体内容
		          {field:'id',title:'工单id',width:50},   
	              {field:'billNo',title:'工单号',width:50},   
	              {field:'installBillNo',title:'安装单号',width:50},   
	              {field:'customerPhone',title:'用户手机号',width:50},   
	              {field:'customerName',title:'用户姓名',width:50},
	              {field:'customerAdd',title:'用户住址',width:50},
	              {field:'billStt',title:'工单状态',width:50,
	            	  //状态，0待分派，1待处理，2（师傅回单后）待回访，3已完成，4退单（选择师傅退单？进入待处理状态），9作废
	            	  formatter:function(value){
	            		  if(value==0){
	            			  return '待接收';      
	            		  }else if(value==1){
	            			  return '已接收';        
	            		  }else if(value==2){
	            			  return '延迟';        
	            		  }else if(value==3){
	            			  return '已完成';        
	            		  }else if(value==9){
	            			  return '作废';        
	            		  }                           
	            	 }  
	              }
	          ]],
	           onRowContextMenu: function(e, rowIndex, rowData) { 
	        	   //右键时触发事件
	                //三个参数：e里面的内容很多，真心不明白，rowIndex就是当前点击时所在行的索引，rowData当前行的数据
	                e.preventDefault(); //阻止浏览器捕获右键事件
	                $(this).datagrid("clearSelections"); //取消所有选中项
	                $(this).datagrid("selectRow", rowIndex); //根据索引选中该行
	                $('#menu').menu('show', {
					//显示右键菜单
	                    left: e.pageX,//在鼠标点击处显示菜单
	                    top: e.pageY
	                });
	            }
		
})
}

function viewData(){
	var rows=datagrid.datagrid('getSelections');
	var ctx_val = $("#context_val").val();
	var id = rows[0].id;
	$("#id").val(id);
	//$("#submitForm").attr("action",ctx_val+"/workBill/viewBillById?id="+id);
	//$("#submitForm").submit();
	
	var iframeName = new Date().getTime();
	window.parent.addTabInSon("安装单详情",iframeName)
	$("#submitForm").attr("target",iframeName);
	$("#submitForm").attr("action",ctx_val+"/installBill/viewBillById?id="+id);
	$("#submitForm").submit();
}
</script>
</head>
<body class="easyui-layout layout" style="background: #fff;"> 
<input type="hidden" value="${ctx}" id="context_val">
	<div id="imgShow"  style="position: absolute;display:none;border: 4px #ccc solid ;z-index:10;background-color:#fff;padding:5px;"><img src="" width="150px"></div>
	<div  region="north" border="false" title="工单搜索" collapsed="false"
		style="height: 80px; overflow:hidden;background: #eee;border-bottom:1px solid #ddd" align="left">
		<form id="searchForm">
			<table style="height: 100%;width:auto;">
				<tr>
					<td>来电号码：</td>
					<td><input class="easyui-textbox" type="text" name="customerPhone" id="customerPhone" ></input> </td>
					<td>安装单状态：</td>
					<td>
	   				<select class="easyui-combobox" editable=false name="billStt" id="billStt">
	   					<option value="">--请选择--</option>
	   					<option value="0">待接收</option>
	   					<option value="1">已接受</option>
	   					<option value="3">完成</option>
	   					<option value="2">延迟</option>
	   				</select>
	   				</td>
	   				<td>请求类型:</td>
		   			<td>
		   				<select class="easyui-combobox" editable=false name="requestType" id="requestType">
		   					<option value="">--请选择--</option>
		   					<option value="0">维修</option>
		   					<option value="1">安装</option>
		   					<option value="2">投诉</option>
		   				</select>
					</td>
		   			<td>紧急度:</td>
		   			<td>
		   				<select value=1 class="easyui-combobox" editable=false name="emergentType" id="emergentType">
		   					<option value="">--请选择--</option>
		   					<option value="0">不紧急</option>
		   					<option value="1">一般</option>
		   					<option value="2">紧急</option>
		   				</select>
		   			</td>
					<td  align="center"><a href="javascript:void(0);" class="easyui-linkbutton"
							iconCls="icon-search" onclick="searchWorkBill();">查询</a></td>	
				</tr>
				<tr>
					<td>被分派人：</td>
					<td><input class="easyui-textbox" type="text" name="deployEmpName" id="deployEmpName" ></input></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</table>
		</form>
		
	</div>
	<div region="center" border="false">

		<table id="data"></table>
		<div id="menu" class="easyui-menu" style="width: 80px; display: none;">
    		<div onclick="viewData();" >查看</div>
    		<div onclick="deleteData();" iconCls="icon-del" >分派</div>
    		<div>指定结束</div>
    		<div>废单</div>
		</div>
		<div id="dialog"  style="width:500px;height:250px;display:none;"> 
				<span id="dialogText"></span>
		</div>

		
	</div>
	<!-- 
<form id="workBillForm" action="${ctx}/workBill/viewBillById" method="POST">
<input type="text"  name="id" id="id" ></input>
<button type="submit">查询</button>
</form>
<br/>
 -->
<script type="text/javascript" src="${ctx}/static/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/locale/easyui-lang-zh_CN.js"></script>

<form action="" id="submitForm" method="post" style="display:none;">
	<input type="text" id="id"/>
</form>
</body>
</html>